package com.job.DQH.dqh716.inClass;

import java.util.Random;

public class StrbEX01 {
    public static void main(String[] args) {
        //向一个字符串中每隔2字符插入随机字母
        String letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        long mills = System.currentTimeMillis();
        StringBuffer stbf = new StringBuffer(mills+"");//或者写String.valueOf(mills)
        System.out.println(stbf);
        Random ran = new Random();
        int insertIndex = 2;

        for (int i = 0; i <5 ; i++) {
            stbf.insert(insertIndex,letters.charAt(ran.nextInt(letters.length())));
            insertIndex += 3;
        }

        System.out.println(stbf);

        //抽取字符串中的数字
        String str1 = "168daw81dsdad68aawd6a4d6a8wd468d44a6wd84w";
        StringBuffer stbf2 = new StringBuffer(str1);
        StringBuffer num = new StringBuffer();
        for (int i = 0; i <str1.length() ; i++) {
            if(Character.isDigit(stbf2.charAt(i))){
                num.append(stbf2.charAt(i));
            }
        }
        //Integer i = Integer.parseInt(num.toString());//太大了给不了？
        System.out.println(num);
    }
}
